package shake.context;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.google.inject.Singleton;

@Singleton
public class NameResolver {

	Map<String, Class<?>> map = new ConcurrentHashMap<String, Class<?>>();
	Map<Class<?>, String> revers = new ConcurrentHashMap<Class<?>, String>();

	public Class<?> get(String name) {
		return map.get(name);
	}

	public String getName(Class<?> clazz) {
		return revers.get(clazz);

	}

	public void put(String name, Class<?> clazz) {
		map.put(name, clazz);
		revers.put(clazz, name);
	}

	Map<String, Integer> precednece = new ConcurrentHashMap<String, Integer>();

	public void putPrecedence(String name, int precedence) {
		precednece.put(name, precedence);
	}

	public int getPrecednece(String name) {
		if (!precednece.containsKey(name)) {
			return -1;
		}
		return precednece.get(name);
	}
}
